/**
 * 获取二叉树的深度
 */

 function depth(bt) {
     if (bt === null) return 0
     if (bt.leftChild === null && bt.rightChild === null) return 1
     const lDepth = depth(bt.leftChild)
     const rDepth = depth(bt.rightChild)
     return 1 + Math.max(lDepth, rDepth)
 }

 const a = new TreeNode('A')
 const b = new TreeNode('B')
 const c = new TreeNode('C')
 const d = new TreeNode('D')
 const e = new TreeNode('E')
 const f = new TreeNode('F')
 const g = new TreeNode('G')
 const h = new TreeNode('H')
 
 
 a.leftChild = b
 a.rightChild = c
 b.leftChild = d
 b.rightChild = e
 e.leftChild = g
 e.rightChild = h
 c.leftChild = f

console.log( depth(a) )
